<template>
	<view>
		<!-- <top-navbar title="提交下单"></top-navbar> -->
		<view class="top">
			<!-- #ifdef MP || APP-PLUS -->
			<view class="sys-head">
				<view class="sys-bar" :style="{height:sysHeight  + 'px'}"></view>
				<!-- #ifdef MP -->
				<view class="sys-title">
					<text class="iconfont icon-fanhui1" @click="back"></text> 
					提交下单
				</view>
				<!-- #endif -->
				<!-- <view class="bg" :style="{height:sysHeight}"></view> -->
			</view>
			<view class="" :style="{height:sysHeight + 'px'}"></view>
			<view class="" style="height:43px"></view>
			<!-- #endif -->
		</view>
		<view class='order-submission'>
			<!--  :style="store_self_mention ? '':'padding-top:10rpx'" -->
			<view class="allAddress" :style="ship_type == 3 ? 'padding-top:100rpx' : 'padding-top:10rpx'">
				<view class="nav acea-row" v-if="ship_type == 3">
					<view class="item" :class="shippingType == 0 ? 'on' : 'on2'" @tap="addressType(0)"
						v-if='store_self_mention'></view>
					<view class="item" :class="shippingType == 1 ? 'on' : 'on2'" @tap="addressType(1)"
						v-if='store_self_mention'></view>
				</view>
				<view class='address acea-row row-between-wrapper' @tap='onAddress' v-if='shippingType == 0 && (ship_type == 1 || ship_type == 3)'>
					<view class='addressCon' v-if="addressInfo.real_name">
						<view class='name'>{{addressInfo.real_name}}
							<text class='phone'>{{addressInfo.phone}}</text>
						</view>
						<view class="line1">
							<text class='default font-color'
								v-if="addressInfo.is_default">[默认]</text>{{addressInfo.province}}{{addressInfo.city}}{{addressInfo.district}}{{addressInfo.detail}}
						</view>
						<!-- <view class='setaddress'>设置收货地址</view> -->
					</view>
					<view class='addressCon' v-else>
						<view class='setaddress'>设置收货地址</view>
					</view>
					<view class='iconfont icon-jiantou'></view>
				</view>
				<view class='address acea-row row-between-wrapper' v-if='shippingType == 1 && (ship_type == 2 || ship_type == 3)' @tap="showStoreList">
					<block v-if="storeList.length>0">
						<view class='addressCon'>
							<view class='name'>{{system_store.name}}
								<text class='phone'>{{system_store.phone}}</text>
							</view>
							<view class="line1"> {{system_store.address}}{{", " + system_store.detailed_address}}</view>
						</view>
						<view class='iconfont icon-jiantou'></view>
					</block>
					<block v-else>
						<view>暂无门店信息</view>
					</block>
				</view>
				<view class='line'>
					<image src='/static/images/line.jpg'></image>
				</view>
			</view>
			<view 
			class="submission_time" 
			v-if="cartInfo.length > 0 && cartInfo[0].productInfo.store_type != 1 && (cartInfo[0].productInfo.combination != 1 || cartInfo[0].productInfo.from != 1)" 
			style="margin-bottom: 10rpx;"> 
				<!-- 月配商品 -->
				<view 
					class="submission_time1 acea-row row-between-wrapper" 
					v-if="cartInfo[0].productInfo.store_type == 2 && (cartInfo[0].productInfo.combination != 1 || cartInfo[0].productInfo.from != 1)">
					<text>首次{{ shippingType == 0 ? '配送' : '自提' }}时间</text>
					<text>{{ cartInfo[0].receive_time.days + ' ' + cartInfo[0].receive_time.name }}</text>
				</view>
				<!-- 自选日期商品 -->
				<view class="submission_time2 acea-row row-between-wrapper" v-if="cartInfo[0].productInfo.store_type == 3">
					<text>送达日期</text>
					<text>{{ cartInfo[0].receive_time.days + ' ' + cartInfo[0].receive_time.name }}</text>
				</view>
			</view>
			<orderGoods :cartInfo="cartInfo" :isWeikuan="isWeikuan"></orderGoods>
			
			<view class='wrapper'>
				<view 
					class='item acea-row row-between-wrapper'
					v-if="shippingType == 1 && cartInfo[0].productInfo.store_type == 1"> 
					<view style="color: #F62C2C;">自提时间</view>
					<view class='discount acea-row' style="align-items: center;">
						<uni-datetime-picker
							type="date" 
							:border="false" 
							v-model="datetimesingle" 
							@change="changeLog" 
							:clearIcon="false"/>
						<text class="text-red">{{week}}</text>
						<text class='iconfont icon-jiantou'></text>
					</view>
				</view>
				<view class='item acea-row row-between-wrapper' @tap='couponTap'
					v-if="!pinkId && !BargainId && !combinationId && !seckillId&& !noCoupon && !discountId">
					<view>优惠券</view>
					<view class='discount'>{{couponTitle}}
						<text class='iconfont icon-jiantou'></text>
					</view>
				</view>
				<view class='item acea-row row-between-wrapper'
					v-if="!pinkId && !BargainId && !combinationId && !seckillId">
					<view>积分抵扣</view>
					<view class='discount acea-row row-middle'>
						<view class=""> 
							<view class="acea-row row-right" style="font-size: 24rpx;">
								{{useIntegral ? "剩余积分":"当前积分"}}
								<text style="color: #a7cf54; margin-right: 20rpx;">{{integral || 0}}</text>
							</view>
							<view class="num" style="font-size: 24rpx;" v-if="useIntegral">
								本次最多可抵扣{{parseFloat(integral_price).toFixed(2)}}元
							</view>
						</view>
						<checkbox-group @change="ChangeIntegral">
							<checkbox :disabled="integral<=0 && !useIntegral" :checked='useIntegral ? true : false' />
						</checkbox-group>
					</view>
				</view>
				<!-- <view v-if="invoice_func || special_invoice" class='item acea-row row-between-wrapper' @tap="goInvoice">
					<view>开具发票</view>
					<view class='discount'>
						{{invTitle}}
						<text class='iconfont icon-jiantou'></text>
					</view>
				</view> -->
				<view class='item acea-row row-between-wrapper' v-if="priceGroup.vipPrice > 0 && userInfo.vip && !pinkId && !BargainId && !combinationId && !seckillId">
					<view>会员优惠</view>
					<view class='discount'>-￥{{priceGroup.vipPrice}}</view>
				</view>
				<!-- <view class='item acea-row row-between-wrapper' v-if='shippingType==0'>
					<view>快递费用</view>
					<view class='discount' v-if='priceGroup.storePostage > 0'>+￥{{priceGroup.storePostage}}</view>
					<view class='discount' v-else>免运费</view>
				</view> -->
				<!-- 祝福卡 -->
				<view class="greeting_card" v-if="showGreet == 1">
					<view class="greeting_hd acea-row row-between-wrapper">
						<text>祝福卡({{ bless_card_price }}元/张)</text>
						<switch 
							:checked="isGreet" 
							@change="greetingChange" 
							color="#a7cf54" 
							style="transform:scale(0.7); margin-right: -20rpx;" 
						/>
					</view>
					<view class="inp_area" v-if="isGreet">
						<textarea v-model="blessing_words" placeholder="请在此输入祝福语" style="margin-top: 15rpx;" />
						<input v-model="chenghu" placeholder="请在此输入称呼" />
					</view>
				</view>
				<!-- 忌讳 -->
				<view class="greeting_card" style="padding-top: 0;" v-if="showTaboo == 1">
					<view class="greeting_hd acea-row row-between-wrapper" style="padding-top: 10rpx; border-top: 1px solid #eee;">
						<text>忌讳</text>
						<switch 
							:checked="isTaboo" 
							@change="tabooChange" 
							color="#a7cf54" 
							style="transform:scale(0.7); margin-right: -20rpx;"
						/>
					</view>
					<view class="inp_area" v-if="isTaboo">
						<textarea v-model="taboo" placeholder="您有什么忌讳请写下来" style="height: 150rpx; margin-top: 15rpx;" />
					</view>
				</view>
				<!-- <view v-if="shippingType == 1">
					<view class="item acea-row row-between-wrapper">
						<view>联系人</view>
						<view class="discount">
							<input style="text-align: right;" v-model="contacts" type="text" placeholder="请填写您的联系姓名"
								placeholder-class="placeholder"></input>
						</view>
					</view>
					<view class="item acea-row row-between-wrapper">
						<view>联系电话</view>
						<view class="discount">
							<input style="text-align: right;" v-model="contactsTel" type="text" placeholder="请填写您的联系电话"
								placeholder-class="placeholder"></input>
						</view>
					</view>
				</view> -->
				
				<!-- <view class='item acea-row row-between-wrapper' wx:else>
		      <view>自提门店</view>
		      <view class='discount'>{{system_store.name}}</view>
		    </view> -->
				<!-- <view class='item' v-if="textareaStatus">
					<view>备注信息</view>
					<view class="placeholder-textarea">
						<textarea ref='textarea' v-if="!coupon.coupon" @input='bindHideKeyboard' :maxlength="150"
							name="mark">
						</textarea>
						<view class="placeholder" @click="clickTextArea" v-show="!mark">
							请添加备注（150字以内）
						</view>
					</view>
				</view> -->
			</view>
			<!-- <view class='wrapper'>
				<view class='item'>
					<view>支付方式</view>
					<view class='list'>
						<view class='payItem acea-row row-middle' :class='active==index ?"on":""' @tap='payItem(index)' v-for="(item,index) in cartArr"
						 :key='index' v-if="item.payStatus==1">
							<view class='name acea-row'>
								<view class='iconfont animated' :class='(item.icon) + " " + (animated==true&&active==index ?"bounceIn":"")'></view>{{item.name}}
							</view>
							<view class='tip'>{{item.title}} <span v-if="item.value == 'yue'">{{item.number}}</span> </view>
						</view>
					</view>
				</view>
			</view> -->
			<view class='moneyList'>
				<view class='item acea-row row-between-wrapper'>
					<view>商品总价：</view>
					<view class='money'>
						￥{{(parseFloat(priceGroup.totalPrice)+parseFloat(priceGroup.vipPrice)).toFixed(2)}}</view>
				</view>
				<view class='item acea-row row-between-wrapper' v-if="priceGroup.storePostage > 0">
					<view>配送运费：</view>
					<view class='money'>
						￥{{(parseFloat(priceGroup.storePostage)+parseFloat(priceGroup.storePostageDiscount)).toFixed(2)}}
					</view>
				</view>
				<view class='item acea-row row-between-wrapper'
					v-if="priceGroup.vipPrice > 0 && userInfo.vip && !pinkId && !BargainId && !combinationId && !seckillId && !discountId">
					<view>会员商品优惠：</view>
					<view class='money'>-￥{{parseFloat(priceGroup.vipPrice).toFixed(2)}}</view>
				</view>
				<view class='item acea-row row-between-wrapper' v-if="priceGroup.storePostageDiscount > 0">
					<view>会员运费优惠：</view>
					<view class='money'>-￥{{parseFloat(priceGroup.storePostageDiscount).toFixed(2)}}</view>
				</view>
				<view class='item acea-row row-between-wrapper' v-if="coupon_price > 0">
					<view>优惠券抵扣：</view>
					<view class='money'>-￥{{parseFloat(coupon_price).toFixed(2)}}</view>
				</view>
				<view class='item acea-row row-between-wrapper' v-if="integral_price > 0">
					<view>积分抵扣：</view>
					<view class='money'>-￥{{parseFloat(integral_price).toFixed(2)}}</view>
				</view>
				<!-- <view class='item acea-row row-between-wrapper' v-if="priceGroup.storePostage > 0">
					<view>运费：</view>
					<view class='money'>+￥{{priceGroup.storePostage}}</view>
				</view>
				<view class='item acea-row row-between-wrapper' v-if="priceGroup.storePostageDiscount > 0">
					<view>会员运费抵扣：</view>
					<view class='money'>-￥{{priceGroup.storePostageDiscount}}</view>
				</view> -->
			</view>
			<!-- 券包, 支付方式 -->
			<view class="padding20">
				<coupons v-if="couponList.couponData" :couponList="couponList" @switchChange="couponChange"></coupons>
				<view class="pay_type" @click="openPayType">
					<text class="title">支付方式</text>
					<view>
						<text class="type">{{ paytypeTxt }}</text>
						<text class="iconfont icon-xiangyou"></text>
					</view>
				</view>
			</view>
			
			<view style='height:120rpx;'></view>
			<view class='footer acea-row row-between-wrapper'>
				<view>合计:
					<text class='font-color'>￥{{totalPrice || 0}}</text>
				</view>
				<view class='settlement' style='z-index:100' @tap="payCheck">立即结算</view>
			</view>
		</view>
		<view class="alipaysubmit" v-html="formContent"></view>
		<couponListWindow :coupon='coupon' @ChangCouponsClone="ChangCouponsClone" :openType='openType' :cartId='cartId'
			@ChangCoupons="ChangCoupons"></couponListWindow>
		<addressWindow ref="addressWindow" @changeTextareaStatus="changeTextareaStatus" :news='news' :address='address'
			:pagesUrl="pagesUrl" @OnChangeAddress="OnChangeAddress" @changeClose="changeClose"></addressWindow>
		<!-- #ifdef MP -->
		<!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
		<!-- #endif -->
		<!-- <home v-show="!invShow"></home> -->
		<invoice-picker :inv-show="invShow" :inv-list="invList" :inv-checked="invChecked" :is-special="special_invoice"
			:url-query="urlQuery" @inv-close="invClose" @inv-change="invChange" @inv-cancel="invCancel">
		</invoice-picker>
		<!-- <payment :payMode="cartArr" :pay_close="pay_close" :isCall="true" :totalPrice="totalPrice.toString()"
			@changePayType="changePayType" @onChangeFun="onChangeFun"></payment> -->
		
		<!-- 选择支付方式 -->
		<wyb-popup ref="popup" type="bottom" radius="6" :showCloseIcon="false">
		    <view class="popup-content payment">
		        <view class="title">选择支付方式<text class="iconfont icon-guanbi" @click='close'></text></view>
				<view class="item acea-row row-between-wrapper" v-for="(item,index) in cartArr" :key="index"
					v-if='item.payStatus' @click="payTypeClick(item.number || 0 , item.value, index, item.name)">
					<view class="left acea-row row-between-wrapper">
						<view class="iconfont" :class="item.icon"></view>
						<view class="text">
							<view class="name">{{item.name}}</view>
							<view class="info" v-if="item.value == 'yue'">
								{{item.title}} 
								<span class="money">￥{{ item.number || '0.00' }}</span>
								<text class="recharge" @click.stop="recharge">去充值</text>
							</view>
							<view class="info" v-else>{{item.title}}</view>
						</view>
					</view>
					<view class="iconfont" :class="active==index?'icon-xuanzhong11 font-color':'icon-weixuan'"></view>
				</view>
		    </view>
		</wyb-popup>
	</view>
</template>
<script>
	import {
		orderPay,
		orderConfirm,
		getCouponsOrderPrice,
		orderCreate,
		postOrderComputed
	} from '@/api/order.js';
	import {
		getAddressDefault,
		getAddressDetail,
		invoiceList,
		invoiceOrder
	} from '@/api/user.js';
	import {
		openPaySubscribe
	} from '@/utils/SubscribeMessage.js';
	import {
		storeListApi
	} from '@/api/store.js';
	import {
		CACHE_LONGITUDE,
		CACHE_LATITUDE
	} from '@/config/cache.js';
	import couponListWindow from '@/components/couponListWindow';
	import coupons from '@/components/coupons/coupons.vue';
	import addressWindow from '@/components/addressWindow';
	import orderGoods from '@/components/orderGoods';
	import home from '@/components/home';
	import invoicePicker from '@/components/invoicePicker';
	import wybPopup from '@/components/wyb-popup/wyb-popup.vue';
	import {
		toLogin
	} from '@/libs/login.js';
	import {
		mapGetters
	} from "vuex";
	// #ifdef MP
	import authorize from '@/components/Authorize';
	// #endif
	import payment from '@/components/payment';
	// #ifdef APP-PLUS || MP
	let sysHeight = uni.getSystemInfoSync().statusBarHeight;
	// #endif
	// #ifndef APP-PLUS || MP
	let sysHeight = 0;
	// #endif
	export default {
		components: {
			payment,
			invoicePicker,
			couponListWindow,
			addressWindow,
			orderGoods,
			home,
			coupons,
			wybPopup,
			// #ifdef MP
			authorize
			// #endif
		},
		data() {
			return {
				textareaStatus: true,
				sysHeight: sysHeight,
				//支付方式
				cartArr: [{
						"name": "微信支付",
						"icon": "icon-weixin2",
						value: 'weixin',
						title: '使用微信快捷支付',
						payStatus: 1,
					},
					{
						"name": "支付宝支付",
						"icon": "icon-zhifubao",
						value: 'alipay',
						title: '使用线上支付宝支付',
						payStatus: 1,
					},
					{
						"name": "余额支付",
						"icon": "icon-yuezhifu",
						value: 'yue',
						title: '可用余额:',
						payStatus: 1,
					},
					{
						"name": "线下支付",
						"icon": "icon-yuezhifu1",
						value: 'offline',
						title: '选择线下付款方式',
						payStatus: 2,
					}
				],
				formContent: '',
				payType: 'weixin', //支付方式
				openType: 1, //优惠券打开方式 1=使用
				active: 0, //支付方式切换
				coupon: {
					coupon: false,
					list: [],
					statusTile: '立即使用'
				}, //优惠券组件
				address: {
					address: false
				}, //地址组件
				addressInfo: {}, //地址信息
				pinkId: 0, //拼团id
				addressId: 0, //地址id
				couponId: 0, //优惠券id
				couponType: 0, // 优惠券类型
				cartId: '', //购物车id
				BargainId: 0,
				combinationId: 0,
				seckillId: 0,
				discountId: 0,
				userInfo: {}, //用户信息
				mark: '', //备注信息
				couponTitle: '请选择', //优惠券
				coupon_price: 0, //优惠券抵扣金额
				useIntegral: false, //是否使用积分
				integral_price: 0, //积分抵扣金额
				integral: 0,
				ChangePrice: 0, //使用积分抵扣变动后的金额
				formIds: [], //收集formid
				status: 0,
				is_address: false,
				toPay: false, //修复进入支付时页面隐藏从新刷新页面
				shippingType: 0,
				system_store: {},
				storePostage: 0,
				contacts: '',
				contactsTel: '',
				mydata: {},
				storeList: [],
				store_self_mention: 0,
				cartInfo: [],
				priceGroup: {},
				animated: false,
				totalPrice: 0,
				integralRatio: "0",
				pagesUrl: "",
				orderKey: "",
				// usableCoupon: {},
				offlinePostage: "",
				isAuto: false, //没有授权的不会自动授权
				isShowAuth: false, //是否隐藏授权
				from: '',
				news: 1,

				invTitle: '不开发票',
				special_invoice: false,
				invoice_func: false,
				header_type: '',
				invShow: false,
				invList: [],
				invChecked: '',
				urlQuery: '',
				pay_close: false,
				noCoupon: 0,
				isGreet: false, //祝福语开关
				showGreet: 0, //是否展示祝福卡
				isTaboo: false, // 忌讳开关
				showTaboo: 0, // 是否展示忌讳
				couponList: {},
				// paytype: 'weixin',
				paytypeTxt: '微信支付',
				datetimesingle: '', // 普通商品自提时间
				ship_type: 1, // 配送方式
				blessing_words: '',
				chenghu: '',
				taboo: '',
				useCouponpack: false, // 券包开关
				bless_card_price: 0, // 祝福卡价格
				week: '',
				isWeikuan: 0 // 尾款支付
			};
		},
		computed: mapGetters(['isLogin']),
		onLoad: function(options) {
			// #ifdef H5
			this.from = this.$wechat.isWeixin() ? 'weixin' : 'weixinh5'
			// #endif
			// #ifdef MP
			this.from = 'routine'
			// #endif
			if (!options.cartId) return this.$util.Tips({
				title: '请选择要购买的商品'
			}, {
				tab: 3,
				url: 1
			});
			this.couponId = options.couponId || 0;
			this.noCoupon = options.noCoupon || 0;
			this.pinkId = options.pinkId ? parseInt(options.pinkId) : 0;
			this.addressId = options.addressId || 0;
			this.cartId = options.cartId;
			this.is_address = options.is_address ? true : false;
			this.news = !options.new || options.new === '0' ? 0 : 1;
			this.invChecked = options.invoice_id || '';
			this.header_type = options.header_type || '1';
			this.couponTitle = options.couponTitle || '请选择'

			switch (options.invoice_type) {
				case '1':
					this.invTitle = '增值税电子普通发票';
					break;
				case '2':
					this.invTitle = '增值税电子专用发票';
					break;
			}
			// #ifndef APP-PLUS
			this.textareaStatus = true;
			// #endif
			if (this.isLogin && this.toPay == false) {
				this.getaddressInfo();
				this.getConfirm();
				this.$nextTick(function() {
					this.$refs.addressWindow.getAddressList();
				})
			} else {
				toLogin();
			}
		},
		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow: function() {
			let _this = this
			uni.$on("handClick", res => {
				if (res) {
					_this.system_store = res.address
				}
				// 清除监听
				uni.$off('handClick');
			})
		},
		methods: {
			back() {
				uni.navigateBack({
					delta: 1
				})
			},
			changeLog(e) {
			    this.datetimesingle = e
			    // console.log('-change事件:', e);
				var weekDay = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
				var myDate = new Date(Date.parse(e));
				this.week = weekDay[myDate.getDay()]
			},
			recharge() {
				uni.navigateTo({
					url: '/pages/users/user_payment/index'
				})
			},
			openPayType() {
				this.$refs.popup.show()
			},
			close() {
				this.$refs.popup.hide()
			},
			payTypeClick(number, paytype, index, name) {
				this.active = index;
				this.payType = paytype;
				// this.number = number;
				this.paytypeTxt = name
				this.$refs.popup.hide()
				// this.$emit('changePayType', paytype)
			},
			// 券包选择
			couponChange(e) {
				this.useCouponpack = e
				// this.coupon.list.push(...this.couponList.couponData)
				if(e) {
					this.couponList.couponOnes.map(el => {
						if(el.available) {
							el.is_use = 0
							this.coupon.list.push(el)
						}
					})
				} else {
					this.couponList.couponOnes.map(el => {
						let index = this.coupon.list.findIndex(item => item.id === el.id)
						if(index != -1) {
							this.coupon.list.splice(index, 1)
						}
					})
				}
				this.computedPrice();
				
			},
			// 祝福卡选择
			greetingChange() {
				this.isGreet = !this.isGreet
				this.computedPrice();
			},
			tabooChange() {
				this.isTaboo = !this.isTaboo
			},
			// 不开发票
			invCancel() {
				this.invChecked = '';
				this.invTitle = '不开发票';
				this.invShow = false;
			},
			// 选择发票
			invChange(id) {
				this.invChecked = id;
				this.invShow = false;
				const result = this.invList.find(item => item.id === id);
				let name = '';
				name += result.header_type === 1 ? '个人' : '企业';
				name += result.type === 1 ? '普通' : '专用';
				name += '发票';
				this.invTitle = name;
			},
			// 关闭发票
			invClose() {
				this.invShow = false;
				this.getInvoiceList()
			},
			getInvoiceList() {
				uni.showLoading({
					title: '正在加载…'
				})
				invoiceList().then(res => {
					uni.hideLoading();
					this.invList = res.data.map(item => {
						item.id = item.id.toString();
						return item;
					});
					const result = this.invList.find(item => item.id == this.invChecked);
					if (result) {
						let name = '';
						name += result.header_type === 1 ? '个人' : '企业';
						name += result.type === 1 ? '普通' : '专用';
						name += '发票';
						this.invTitle = name;
					}
				}).catch(err => {
					uni.showToast({
						title: err,
						icon: 'none'
					});
				});
			},
			/**
			 * 开发票
			 */
			goInvoice: function() {
				this.getInvoiceList()
				this.invShow = true;
				this.urlQuery =
					`new=${this.news}&cartId=${this.cartId}&pinkId=${this.pinkId}&couponId=${this.couponId}&addressId=${this.addressId}&specialInvoice=${this.special_invoice}&couponTitle=${this.couponTitle}`;
			},
			/**
			 * 授权回调事件
			 * 
			 */
			onLoadFun: function() {
				this.getaddressInfo();
				this.getConfirm();
				//调用子页面方法授权后执行获取地址列表
				// this.$scope.selectComponent('#address-window').getAddressList();
			},
			/**
			 * 事件回调
			 *
			 */
			onChangeFun: function(e) {
				let opt = e;
				let action = opt.action || null;
				let value = opt.value != undefined ? opt.value : null;
				action && this[action] && this[action](value);
			},
			payClose: function() {
				this.pay_close = false;
			},
			goPay() {
				// this.pay_close = true;
				let that = this;
				if (!that.cartId) return that.$util.Tips({
					title: '请选择要支付的订单'
				});
				
				if (that.payType == 'yue' && parseFloat(that.userInfo.now_money) < parseFloat(that.totalPrice)) return that.$util.Tips({
					title: '余额不足！'
				});
				uni.showLoading({
					title: '支付中'
				});
			
				orderPay({
					uni: that.cartId,
					paytype: paytype,
					// #ifdef MP 
					'from': 'routine',
					// #endif
					// #ifdef H5
					'from': this.$wechat.isWeixin() ? 'weixin' : 'weixinh5',
					// #endif
					// #ifdef H5
					quitUrl: location.port ? location.protocol + '//' + location.hostname + ':' + location
						.port +
						'/pages/users/order_details/index?order_id=' + this.order_id : location.protocol +
						'//' + location.hostname +
						'/pages/users/order_details/index?order_id=' + this.order_id
					// #endif
					// #ifdef APP-PLUS
					quitUrl: '/pages/users/order_details/index?order_id=' + this.order_id
					// #endif
				}).then(res => {
					let jsConfig = res.data.result.jsConfig;
					switch (paytype) {
						case 'weixin':
							if (res.data.result === undefined) return that.$util.Tips({
								title: '缺少支付参数'
							});
			
							// #ifdef MP
			
							uni.requestPayment({
								timeStamp: jsConfig.timestamp,
								nonceStr: jsConfig.nonceStr,
								package: jsConfig.package,
								signType: jsConfig.signType,
								paySign: jsConfig.paySign,
								success: function(res) {
									uni.hideLoading();
									return that.$util.Tips({
										title: res.msg,
										icon: 'success'
									}, () => {
										that.$emit('onChangeFun', {
											action: 'pay_complete'
										});
									});
								},
								fail: function(e) {
									uni.hideLoading();
									return that.$util.Tips({
										title: '取消支付'
									}, () => {
										that.$emit('onChangeFun', {
											action: 'pay_fail'
										});
									});
								},
								complete: function(e) {
									uni.hideLoading();
									if (e.errMsg == 'requestPayment:cancel') return that.$util
										.Tips({
											title: '取消支付'
										}, () => {
											that.$emit('onChangeFun', {
												action: 'pay_fail'
											});
										});
								},
							});
							// #endif
							// #ifdef H5
							let data = res.data;
							if (data.status == "WECHAT_H5_PAY") {
								uni.hideLoading();
								location.replace(data.result.jsConfig.mweb_url);
								return that.$util.Tips({
									title: "支付成功",
									icon: 'success'
								}, () => {
									that.$emit('onChangeFun', {
										action: 'pay_complete'
									});
								});
							} else {
								that.$wechat.pay(data.result.jsConfig)
									.finally(() => {
										return that.$util.Tips({
											title: "支付成功",
											icon: 'success'
										}, () => {
											that.$emit('onChangeFun', {
												action: 'pay_complete'
											});
										});
									})
									.catch(function() {
										return that.$util.Tips({
											title: '支付失败'
										});
									});
							}
							// #endif
							// #ifdef APP-PLUS
							uni.requestPayment({
								provider: 'wxpay',
								orderInfo: jsConfig,
								success: (e) => {
									let url = '/pages/order_pay_status/index?order_id=' + orderId +
										'&msg=支付成功';
									uni.showToast({
										title: "支付成功"
									})
									setTimeout(res => {
										that.$emit('onChangeFun', {
											action: 'pay_complete'
										});
									}, 2000)
								},
								fail: (e) => {
									uni.showModal({
										content: "支付失败",
										showCancel: false,
										success: function(res) {
											if (res.confirm) {
												that.$emit('onChangeFun', {
													action: 'pay_fail'
												});
											} else if (res.cancel) {}
										}
									})
								},
								complete: () => {
									uni.hideLoading();
								},
							});
							// #endif
							break;
						case 'yue':
							uni.hideLoading();
							return that.$util.Tips({
								title: res.msg,
								icon: 'success'
							}, () => {
								that.$emit('onChangeFun', {
									action: 'pay_complete'
								});
							});
							break;
						case 'offline':
							uni.hideLoading();
							return that.$util.Tips({
								title: res.msg,
								icon: 'success'
							}, () => {
								that.$emit('onChangeFun', {
									action: 'pay_complete'
								});
							});
							break;
						case 'alipay':
							uni.hideLoading();
							//#ifdef H5
							if (this.$wechat.isWeixin()) {
								uni.redirectTo({
									url: `/pages/users/alipay_invoke/index?id=${res.data.result.order_id}&pay_key=${res.data.result.pay_key}`
								});
							} else {
								uni.hideLoading();
								that.formContent = res.data.result.jsConfig;
								that.$nextTick(() => {
									document.getElementById('alipaysubmit').submit();
								});
							}
							//#endif
							// #ifdef MP
							uni.navigateTo({
								url: `/pages/users/alipay_invoke/index?id=${res.data.result.order_id}&link=${res.data.result.jsConfig.qrCode}`
							});
							// #endif
							// #ifdef APP-PLUS
							uni.requestPayment({
								provider: 'alipay',
								orderInfo: jsConfig,
								success: (e) => {
									uni.showToast({
										title: "支付成功"
									})
									setTimeout(res => {
										that.$emit('onChangeFun', {
											action: 'pay_complete'
										});
									}, 2000)
			
								},
								fail: (e) => {
									uni.showModal({
										content: "支付失败",
										showCancel: false,
										success: function(res) {
											if (res.confirm) {
												that.$emit('onChangeFun', {
													action: 'pay_fail'
												});
											} else if (res.cancel) {}
										}
									})
								},
								complete: () => {
									uni.hideLoading();
								},
							});
							// #endif
							break;
					}
				}).catch(err => {
					uni.hideLoading();
					return that.$util.Tips({
						title: err0
					}, () => {
						that.$emit('onChangeFun', {
							action: 'pay_fail'
						});
					});
				})
				
			},
			payCheck(type) {
				// this.payType = type;
				this.SubOrder();
			},
			/**
			 * 获取门店列表数据
			 */
			getList: function() {
				let longitude = uni.getStorageSync("user_longitude"); //经度
				let latitude = uni.getStorageSync("user_latitude"); //纬度
				let data = {
					latitude: latitude, //纬度
					longitude: longitude, //经度
					page: 1,
					limit: 10
				}
				storeListApi(data).then(res => {
					let list = res.data.list.list || [];
					this.$set(this, 'storeList', list);
					this.$set(this, 'system_store', list[0]);
				}).catch(err => {})
			},
			// 关闭地址弹窗；
			changeClose: function() {
				this.$set(this.address, 'address', false);
			},
			/*
			 * 跳转门店列表
			 */
			showStoreList: function() {

				let _this = this
				if (this.storeList.length > 0) {
					uni.navigateTo({
						url: '/pages/users/goods_details_store/index'
					})
				}
			},
			changePayType(type) {
				this.payType = type
				this.computedPrice()
			},
			computedPrice: function() {
				let shippingType = this.shippingType;
				postOrderComputed(this.orderKey, {
					addressId: this.addressId,
					useIntegral: this.useIntegral ? 1 : 0,
					couponId: this.couponId,
					couponType: this.couponType,
					couponPackId: this.useCouponpack ? this.couponList.id : '',
					shipping_type: parseInt(shippingType) + 1,
					payType: this.payType,
					bless_card: this.isGreet ? 1 : 0
				}).then(res => {
					let result = res.data.result;
					if (result) {
						this.totalPrice = result.pay_price;
						this.integral_price = result.deduction_price;
						this.coupon_price = result.coupon_price;
						this.integral = this.useIntegral ? result.SurplusIntegral : this.userInfo.integral;
						this.$set(this.priceGroup, 'storePostage', shippingType == 1 ? 0 : result.pay_postage);
						this.$set(this.priceGroup, 'storePostageDiscount', result.storePostageDiscount);
					}
				})
			},
			addressType: function(e) {
				let index = e;
				this.shippingType = parseInt(index);
				this.computedPrice();
				if (index == 1) this.getList();
			},
			bindPickerChange: function(e) {
				let value = e.detail.value;
				this.shippingType = value;
				this.computedPrice();
			},
			ChangCouponsClone: function() {
				this.$set(this.coupon, 'coupon', false);
			},
			changeTextareaStatus: function() {
				for (let i = 0, len = this.coupon.list.length; i < len; i++) {
					this.coupon.list[i].use_title = '';
					this.coupon.list[i].is_use = 0;
				}
				this.textareaStatus = true;
				this.status = 0;
				this.$set(this.coupon, 'list', this.coupon.list);
			},
			/**
			 * 处理点击优惠券后的事件
			 * 
			 */
			ChangCoupons: function(e) {
				// this.usableCoupon = e
				// this.coupon.coupon = false
				
				let index = e,
					list = this.coupon.list,
					couponType = 0,
					couponTitle = '请选择',
					couponId = 0;

				if(list[index].available == false) return this.$util.Tips({
						title: '此优惠券不可用'
					});
					
				for (let i = 0, len = list.length; i < len; i++) {
					if (i != index) {
						list[i].use_title = '';
						list[i].is_use = 0;
					}
				}
				
				if (list[index].is_use == 1) {
					//不使用优惠券
					list[index].use_title = '';
					list[index].is_use = 0;
				} else {
					//使用优惠券
					list[index].use_title = '不使用';
					list[index].is_use = 1;
					couponTitle = list[index].coupon_title;
					couponId = list[index].id;
					couponType = list[index].couponType == 0 ? list[index].couponType : 1
				}
				this.couponTitle = couponTitle;
				this.couponId = couponId;
				this.couponType = couponType;
				this.$set(this.coupon, 'coupon', false);
				this.$set(this.coupon, 'list', list);
				this.computedPrice();
			},
			/**
			 * 使用积分抵扣
			 */
			ChangeIntegral: function() {
				this.useIntegral = !this.useIntegral;
				this.computedPrice();
			},
			/**
			 * 选择地址后改变事件
			 * @param object e
			 */
			OnChangeAddress: function(e) {
				this.textareaStatus = true;
				this.addressId = e;
				this.address.address = false;
				this.getaddressInfo();
				this.computedPrice();
			},
			bindHideKeyboard: function(e) {
				this.mark = e.detail.value;
			},
			/**
			 * 获取当前订单详细信息
			 * 
			 */
			getConfirm: function() {
				let that = this;
				// return;
				orderConfirm(that.cartId, that.news).then(res => {
					that.$set(that, 'isWeikuan', res.data.is_pay_weikuan);
					that.$set(that, 'userInfo', res.data.userInfo);
					that.$set(that, 'integral', res.data.userInfo.integral);
					that.$set(that, 'contacts', res.data.userInfo.real_name);
					that.$set(that, 'contactsTel', res.data.userInfo.record_phone || '');
					that.$set(that, 'cartInfo', res.data.cartInfo);
					that.$set(that, 'integralRatio', res.data.integralRatio);
					that.$set(that, 'offlinePostage', res.data.offlinePostage);
					that.$set(that, 'orderKey', res.data.orderKey);
					that.$set(that, 'couponList', res.data.couponPack);
					that.$set(that, 'bless_card_price', res.data.bless_card_price);
					that.$set(that, 'showGreet', res.data.bless_card_switch);
					res.data.cartInfo.map(el => {
						if(el.productInfo.is_taboo == 0) {
							that.$set(that, 'showTaboo', 0);
						}
					})
					that.$set(that, 'priceGroup', res.data.priceGroup);
					that.$set(that, 'totalPrice', that.$util.$h.Add(parseFloat(res.data.priceGroup.totalPrice),
						parseFloat(res.data
							.priceGroup.storePostage)));
					that.$set(that, 'seckillId', parseInt(res.data.seckill_id));
					that.$set(that, 'invoice_func', res.data.invoice_func);
					that.$set(that, 'special_invoice', res.data.special_invoice);
					that.$set(that, 'store_self_mention', res.data.store_self_mention);
					that.$set(that, 'ship_type', res.data.shipping_type);
					if(res.data.shipping_type == 2) {
						that.$set(that, 'shippingType', 1);
						that.getList();
					}
					//微信支付是否开启
					that.cartArr[0].payStatus = res.data.pay_weixin_open || 0
					//支付宝是否开启
					that.cartArr[1].payStatus = res.data.ali_pay_status || 0;
					//#ifdef MP
					that.cartArr[1].payStatus = 0;
					//#endif
					//余额支付是否开启
					// that.cartArr[2].title = '可用余额:' + res.data.userInfo.now_money;
					that.cartArr[2].number = res.data.userInfo.now_money;
					that.cartArr[2].payStatus = res.data.yue_pay_status == 1 ? res.data.yue_pay_status : 0
					if (res.data.offline_pay_status == 2) {
						that.cartArr[3].payStatus = 0
					} else {
						that.cartArr[3].payStatus = 1
					}

					// that.$set(that, 'cartArr', that.cartArr);
					that.$set(that, 'ChangePrice', that.totalPrice);
					that.getBargainId();
					that.getCouponList();
					if (this.addressId) {
						this.computedPrice();
					}
				}).catch(err => {
					return this.$util.Tips({
						title: err
					});
				});
			},
			/*
			 * 提取砍价和拼团id
			 */
			getBargainId: function() {
				let that = this;
				let cartINfo = that.cartInfo;
				let BargainId = 0;
				let combinationId = 0;
				let discountId = 0;
				cartINfo.forEach(function(value, index, cartINfo) {
					BargainId = cartINfo[index].bargain_id,
						combinationId = cartINfo[index].combination_id,
						discountId = cartINfo[index].discount_id
				})
				that.$set(that, 'BargainId', parseInt(BargainId));
				that.$set(that, 'combinationId', parseInt(combinationId));
				that.$set(that, 'discountId', parseInt(discountId));
				if (that.cartArr.length == 3 && (BargainId || combinationId || that.seckillId || discountId)) {
					that.cartArr[2].payStatus = 0;
					that.$set(that, 'cartArr', that.cartArr);
				}
			},
			/**
			 * 获取当前金额可用优惠券
			 * 
			 */
			getCouponList: function() {
				let that = this;
				let data = {
					cartId: this.cartId,
					'new': this.news
				}
				getCouponsOrderPrice(this.totalPrice, data).then(res => {
					res.data.map(el => {
						el.couponType = 0
					})
					that.$set(that.coupon, 'list', res.data);
					that.openType = 1;
					if(that.coupon.list.length > 0) { // 默认使用优惠券
						if(!that.pinkId && !that.BargainId && !that.combinationId && !that.seckillId&& !that.noCoupon && !that.discountId) {
							that.ChangCoupons(0)
						}
					}
				});
			},
			/*
			 * 获取默认收货地址或者获取某条地址信息
			 */
			getaddressInfo: function() {
				let that = this;
				if (that.addressId) {
					getAddressDetail(that.addressId).then(res => {
						res.data.is_default = parseInt(res.data.is_default);
						that.addressInfo = res.data || {};
						that.addressId = res.data.id || 0;
						that.address.addressId = res.data.id || 0;
					})
				} else {
					getAddressDefault().then(res => {
						res.data.is_default = parseInt(res.data.is_default);
						that.addressInfo = res.data || {};
						that.addressId = res.data.id || 0;
						that.address.addressId = res.data.id || 0;
					})
				}
			},
			payItem: function(e) {
				let that = this;
				let active = e;
				that.active = active;
				that.animated = true;
				that.payType = that.cartArr[active].value;
				that.computedPrice();
				setTimeout(function() {
					that.car();
				}, 500);
			},
			couponTap: function() {
				this.coupon.coupon = true;
				// this.coupon.list.forEach((item, index) => {
				// 	if (item.id == this.couponId) {
				// 		item.is_use = 1
				// 	} else {
				// 		item.is_use = 0
				// 	}
				// })
				// this.$set(this.coupon, 'list', this.coupon.list);
			},
			car: function() {
				let that = this;
				that.animated = false;
			},
			onAddress: function() {
				let that = this;
				that.textareaStatus = false;
				that.address.address = true;
				that.pagesUrl = '/pages/users/user_address_list/index?news=' + this.news + '&cartId=' + this.cartId +
					'&pinkId=' +
					this.pinkId +
					'&couponId=' +
					this.couponId;
			},
			payment: function(data) {
				let that = this;
				orderCreate(that.orderKey, data).then(res => {
					if(res.status == 200) {
						let status = res.data.status,
							isSplit = res.data.result.isSplit,
							orderId = res.data.result.orderId,
							jsConfig = res.data.result.jsConfig,
							goPages = '/pages/order_pay_status/index?order_id=' + orderId + '&msg=' + res.msg +
							'&type=3' + '&totalPrice=' + this.totalPrice + '&isSplit=' + isSplit;
						switch (status) {
							case 'ORDER_EXIST':
							case 'EXTEND_ORDER':
							case 'PAY_ERROR':
								uni.hideLoading();
								return that.$util.Tips({
									title: res.msg,
									endtime: 1000
								}, {
									tab: 5,
									url: goPages
								});
								break;
							case 'SUCCESS':
								uni.hideLoading();
								if (that.BargainId || that.combinationId || that.pinkId || that.seckillId || that
									.discountId)
									return that.$util.Tips({
										title: res.msg,
										icon: 'success',
										endtime: 1000
									}, {
										tab: 4,
										url: goPages
									});
								return that.$util.Tips({
									title: res.msg,
									icon: 'success',
									endtime: 1000
								}, {
									tab: 5,
									url: goPages
								});
								break;
							case 'WECHAT_PAY':
								that.toPay = true;
								// #ifdef MP
								/* that.toPay = true; */
								uni.requestPayment({
									timeStamp: jsConfig.timestamp,
									nonceStr: jsConfig.nonceStr,
									package: jsConfig.package,
									signType: jsConfig.signType,
									paySign: jsConfig.paySign,
									success: function(res) {
										uni.hideLoading();
										if (that.BargainId || that.combinationId || that.pinkId || that
											.seckillId || that.discountId)
											return that.$util.Tips({
												title: '支付成功',
												icon: 'success',
												endtime: 1000
											}, {
												tab: 4,
												url: goPages
											});
										return that.$util.Tips({
											title: '支付成功',
											icon: 'success',
											endtime: 1000
										}, {
											tab: 5,
											url: goPages
										});
									},
									fail: function(e) {
										uni.hideLoading();
										return that.$util.Tips({
											title: '取消支付',
											endtime: 1000
										}, {
											tab: 5,
											url: goPages + '&status=2'
										});
									},
									complete: function(e) {
										uni.hideLoading();
										//关闭当前页面跳转至订单状态
										if (res.errMsg == 'requestPayment:cancel') return that.$util
											.Tips({
												title: '取消支付',
												endtime: 1000
											}, {
												tab: 5,
												url: goPages + '&status=2'
											});
									},
								})
								// #endif
								// #ifdef H5
								this.$wechat.pay(res.data.result.jsConfig).then(res => {
									return that.$util.Tips({
										title: '支付成功',
										icon: 'success',
										endtime: 1000
									}, {
										tab: 5,
										url: goPages
									});
								}).catch(res => {
									if (!this.$wechat.isWeixin()) {
										uni.redirectTo({
											url: goPages +
												'&msg=支付失败&status=2'
										})
									}
									if (res.errMsg == 'chooseWXPay:cancel') return that.$util.Tips({
										title: '取消支付'
									}, {
										tab: 5,
										url: goPages + '&status=2'
									});
								})
								// #endif
								// #ifdef APP-PLUS
								uni.requestPayment({
									provider: 'wxpay',
									orderInfo: jsConfig,
									success: (e) => {
										let url = goPages;
										uni.showToast({
											title: "支付成功"
										})
										setTimeout(res => {
											uni.redirectTo({
												url: url
											})
										}, 1000)
									},
									fail: (e) => {
										let url = '/pages/order_pay_status/index?order_id=' + orderId +
											'&msg=支付失败';
										uni.showModal({
											content: "支付失败",
											showCancel: false,
											success: function(res) {
												if (res.confirm) {
													uni.redirectTo({
														url: url
													})
												} else if (res.cancel) {
													console.log('用户点击取消');
												}
											}
										})
									},
									complete: () => {
										uni.hideLoading();
									},
								});
								// #endif
								break;
							case 'PAY_DEFICIENCY':
								uni.hideLoading();
								//余额不足
								return that.$util.Tips({
									title: res.msg,
									endtime: 1000
								}, {
									tab: 5,
									url: goPages + '&status=1'
								});
								break;
							case "WECHAT_H5_PAY": //公众号
								uni.hideLoading();
								that.$util.Tips({
									title: '订单创建成功',
									endtime: 1000
								}, {
									tab: 5,
									url: goPages + '&status=0'
								});
								setTimeout(() => {
									location.href = res.data.result.jsConfig.mweb_url;
								}, 100);
								break;

							case 'ALIPAY_PAY':
								//#ifdef H5
								if (this.from === 'weixin') {
									uni.redirectTo({
										url: `/pages/users/alipay_invoke/index?id=${orderId}&pay_key=${res.data.result.pay_key}`
									});
								} else {
									uni.hideLoading();
									that.formContent = res.data.result.jsConfig;
									that.$nextTick(() => {
										document.getElementById('alipaysubmit').submit();
									})
								}
								//#endif
								// #ifdef MP
								uni.navigateTo({
									url: `/pages/users/alipay_invoke/index?id=${orderId}&link=${jsConfig.qrCode}`
								});
								// #endif
								// #ifdef APP-PLUS
								uni.requestPayment({
									provider: 'alipay',
									orderInfo: jsConfig,
									success: (e) => {
										uni.showToast({
											title: "支付成功"
										})
										let url = '/pages/order_pay_status/index?order_id=' + orderId +
											'&msg=支付成功';
										setTimeout(res => {
											uni.redirectTo({
												url: url
											})
										}, 2000)

									},
									fail: (e) => {
										let url = '/pages/order_pay_status/index?order_id=' + orderId +
											'&msg=支付失败';
										uni.showModal({
											content: "支付失败",
											showCancel: false,
											success: function(res) {
												if (res.confirm) {
													uni.redirectTo({
														url: url
													})
												} else if (res.cancel) {
													console.log('用户点击取消');
												}
											}
										})
									},
									complete: () => {
										uni.hideLoading();
									},
								});
								// #endif
								break;
					}
					} else {
						return that.$util.Tips({
							title: res.msg
						});
					}
				}).catch(err => {
					uni.hideLoading();
					return that.$util.Tips({
						title: err
					});
				});
			},
			clickTextArea() {
				this.$refs.textarea.focus()
			},
			SubOrder: function(e) {
				let that = this,
					data = {};

				if (!that.payType) return that.$util.Tips({
					title: '请选择支付方式'
				});
				if (!that.addressId && !that.shippingType) return that.$util.Tips({
					title: '请选择收货地址'
				});
				if (that.isGreet == 1) {
					if (that.blessing_words == "") {
						return that.$util.Tips({
							title: '请填写祝福语'
						});
					}
					if (that.chenghu == "") {
						return that.$util.Tips({
							title: '请填写您的称呼'
						});
					}
					// if (that.contacts == "" || that.contactsTel == "") {
					// 	return that.$util.Tips({
					// 		title: '请填写联系人或联系人电话'
					// 	});
					// }
					// if (!/^1(3|4|5|7|8|9|6)\d{9}$/.test(that.contactsTel)) {
					// 	return that.$util.Tips({
					// 		title: '请填写正确的手机号'
					// 	});
					// }
					// if (!/^[\u4e00-\u9fa5\w]{2,16}$/.test(that.contacts)) {
					// 	return that.$util.Tips({
					// 		title: '请填写您的真实姓名'
					// 	});
					// }
				}
				if (that.shippingType == 1) {
					if (that.storeList.length == 0) return that.$util.Tips({
						title: '暂无门店,请选择其他方式'
					});
					if(that.cartInfo[0].productInfo.store_type == 1) {
						if(!that.datetimesingle) return that.$util.Tips({
							title: '请选择自提日期'
						});
					}
				}
				data = {
					addressId: that.addressId,
					couponId: that.couponId,
					couponType: that.couponType, // 使用优惠券类型。0=普通，1=券包
					couponPackId: that.useCouponpack ? that.couponList.id : '', // 选中的券包id
					'from': that.from, // 来源
					mark: that.mark, // 订单备注
					'new': that.news, // 是否购物车
					payType: that.payType, // 支付类型
					phone: that.contactsTel,
					real_name: that.contacts,
					shipping_type: that.$util.$h.Add(that.shippingType, 1), // 配送类型
					useIntegral: that.useIntegral, // 使用积分
					bless_card: that.isGreet ? '1' : '0', // 祝福卡【0=不需要，1=需要】
					blessing_words: that.blessing_words, // 祝福语
					chenghu: that.chenghu, // 称呼
					taboo: that.taboo, // 忌讳
					formId: '',
					bargainId: that.BargainId, //砍价id
					combinationId: that.combinationId,
					discountId: that.discountId, //优惠套餐id
					pinkId: that.pinkId, // 拼团id
					seckill_id: that.seckillId, //秒杀商品ID
					store_id: that.system_store ? that.system_store.id : 0, 
					delivery_time: that.datetimesingle,
					'invoice_id': that.invChecked,
					// #ifdef H5
					quitUrl: location.protocol + '//' + location.hostname +
						'/pages/order_pay_status/index?' +
						'&type=3' + '&totalPrice=' + this.totalPrice
					// #endif
					// #ifdef APP-PLUS
					quitUrl: '/pages/users/order_details/index?order_id=' + this.order_id
					// #endif
				};
				if (data.payType == 'yue' && parseFloat(that.userInfo.now_money) < parseFloat(that.totalPrice))
					return that.$util.Tips({
						title: '余额不足！'
					});
				uni.showLoading({
					title: '订单支付中'
				});
				that.payment(data);
				// #ifdef MP
				// openPaySubscribe().then(() => {
				// 	that.payment(data);
				// });
				// #endif
				// #ifndef MP
				// that.payment(data);
				// #endif
			}
		}
	}
</script>

<style lang="scss" scoped>
	.sys-head {
		position: fixed;
		top: 0;
		// position: relative;
		width: 100%;
		background: url(../../../static/images/order_bg.png) no-repeat top;
		background-size: 100%;
		// background: linear-gradient(90deg, $bg-star1 0%, $bg-end1 100%);
		z-index: 999;
		.bg {
			position: absolute;
			left: 0;
			top: 0;
			width: 100%;
			height: 100%;
			
		}
		.icon-fanhui1 {
			margin-right: 20rpx;
			font-size: 32rpx;
		}
		.sys-title {
			z-index: 10;
			position: relative;
			height: 43px;
			text-align: left;
			padding-left: 30rpx;
			line-height: 43px;
			font-size: 36rpx;
			color: #FFFFFF;
		}
	}
	.submission_time {
		width: 100%;
		background-color: #fff;
		padding: 20rpx 30rpx;
		color: #ff5637;
	}
	.gift_item {
		width: 100%;
		background-color: #fff;
		padding: 0 30rpx 30rpx 180rpx;
		font-size: 24rpx;
		.line1 {
			width: 450rpx;
		}
	}
	/deep/uni-checkbox[disabled] .uni-checkbox-input {
		background-color: #eee;
	}
	.pay_type {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 100%;
		height: 110rpx;
		background-color: #fff;
		margin-top: 25rpx;
		padding: 0 30rpx;
		font-size: 30rpx;
		border-radius: 15rpx;
		box-shadow: 0 0 10rpx 5rpx #eee;
		.title {
			color: #999;
		}
		.type {
			font-weight: 700;
			margin-right: 10rpx;
		}
		.icon-xiangyou {
			color: #999;
		}
	}
	.alipaysubmit {
		display: none;
	}

	.order-submission .line {
		width: 100%;
		height: 3rpx;
	}

	.order-submission .line image {
		width: 100%;
		height: 100%;
		display: block;
	}

	.order-submission .address {
		padding: 28rpx 30rpx;
		background-color: #fff;
		box-sizing: border-box;
	}

	.order-submission .address .addressCon {
		width: 610rpx;
		font-size: 26rpx;
		color: #666;
	}

	.order-submission .address .addressCon .name {
		font-size: 30rpx;
		color: #282828;
		font-weight: bold;
		margin-bottom: 10rpx;
	}

	.order-submission .address .addressCon .name .phone {
		margin-left: 50rpx;
	}

	.order-submission .address .addressCon .default {
		margin-right: 12rpx;
	}

	.order-submission .address .addressCon .setaddress {
		color: #333;
		font-size: 28rpx;
	}

	.order-submission .address .iconfont {
		font-size: 35rpx;
		color: #707070;
	}

	.order-submission .allAddress {
		width: 100%;
		// background: linear-gradient(to bottom, #a7cf54 0%, #f2f4ef 100%);
		background: url(../../../static/images/order_bg.png) no-repeat center;
		background-size: 100%;
		// background-image: linear-gradient(to bottom, #e93323 0%, #f5f5f5 100%);
		// background-image: -webkit-linear-gradient(to bottom, #e93323 0%, #f5f5f5 100%);
		// background-image: -moz-linear-gradient(to bottom, #e93323 0%, #f5f5f5 100%);
		// padding-top: 100rpx;
		padding-bottom: 20rpx;
	}

	.order-submission .allAddress .nav {
		width: 710rpx;
		margin: 0 auto;
	}

	.order-submission .allAddress .nav .item {
		width: 355rpx;
		color: #a5ce50;
	}

	.order-submission .allAddress .nav .item.on {
		position: relative;
		width: 250rpx;
	}

	.order-submission .allAddress .nav .item.on::before {
		position: absolute;
		bottom: 0;
		content: "快递配送";
		font-size: 28rpx;
		display: block;
		height: 0;
		width: 336rpx;
		border-width: 0 50rpx 70rpx 0;
		border-style: none solid solid;
		border-color: transparent transparent #fff;
		z-index: 2;
		border-radius: 7rpx 30rpx 0 0;
		text-align: center;
		line-height: 80rpx;
	}

	.order-submission .allAddress .nav .item:nth-of-type(2).on::before {
		content: "到店自提";
		width: 306rpx;
		border-width: 0 0 70rpx 50rpx;
		border-radius: 30rpx 7rpx 0 0;
	}

	.order-submission .allAddress .nav .item.on2 {
		position: relative;
	}

	.order-submission .allAddress .nav .item.on2::before {
		position: absolute;
		bottom: 0;
		content: "到店自提";
		font-size: 28rpx;
		display: block;
		height: 0;
		width: 400rpx;
		border-width: 0 0 60rpx 60rpx;
		border-style: none solid solid;
		border-color: transparent transparent #e6f1d1;
		border-radius: 40rpx 6rpx 0 0;
		text-align: center;
		line-height: 60rpx;
	}

	.order-submission .allAddress .nav .item:nth-of-type(1).on2::before {
		content: "快递配送";
		border-width: 0 40rpx 60rpx 0;
		border-radius: 6rpx 40rpx 0 0;
	}

	.order-submission .allAddress .address {
		width: 710rpx;
		height: 150rpx;
		margin: 0 auto;
	}

	.order-submission .allAddress .line {
		width: 710rpx;
		margin: 0 auto;
	}

	.order-submission .wrapper .item .discount .placeholder {
		color: #ccc;
	}

	.placeholder-textarea {
		position: relative;

		.placeholder {
			position: absolute;
			color: #ccc;
			top: 26rpx;
			left: 30rpx;
		}
	}

	.order-submission .wrapper {
		background-color: #fff;
		margin-top: 13rpx;
	}
	.text-red{ 
		color: #F62C2C;
	}
	.order-submission .wrapper .item {
		padding: 27rpx 30rpx;
		font-size: 30rpx;
		color: #282828;
		border-bottom: 1px solid #f0f0f0;
	}

	.order-submission .wrapper .item .discount {
		font-size: 30rpx;
		color: #999;
	}

	.order-submission .wrapper .item .discount input {
		text-align: end;
	}

	.order-submission .wrapper .item .discount .iconfont {
		color: #515151;
		font-size: 30rpx;
		margin-left: 15rpx;
	}

	.order-submission .wrapper .item .discount .num {
		font-size: 32rpx;
		margin-right: 20rpx;
	}

	.order-submission .wrapper .item .shipping {
		font-size: 30rpx;
		color: #999;
		position: relative;
		padding-right: 58rpx;
	}

	.order-submission .wrapper .item .shipping .iconfont {
		font-size: 35rpx;
		color: #707070;
		position: absolute;
		right: 0;
		top: 50%;
		transform: translateY(-50%);
		margin-left: 30rpx;
	}

	.order-submission .wrapper .item textarea {
		background-color: #f9f9f9;
		width: 690rpx;
		height: 140rpx;
		border-radius: 3rpx;
		margin-top: 30rpx;
		padding: 25rpx 28rpx;
		box-sizing: border-box;
	}

	.order-submission .wrapper .item .placeholder {
		color: #ccc;
	}

	.order-submission .wrapper .item .list {
		margin-top: 35rpx;
	}

	.order-submission .wrapper .item .list .payItem {
		border: 1px solid #eee;
		border-radius: 6rpx;
		height: 86rpx;
		width: 100%;
		box-sizing: border-box;
		margin-top: 20rpx;
		font-size: 28rpx;
		color: #282828;
	}

	.order-submission .wrapper .item .list .payItem.on {
		border-color: #fc5445;
		color: #e93323;
	}

	.order-submission .wrapper .item .list .payItem .name {
		width: 50%;
		text-align: center;
		border-right: 1px solid #eee;
		padding-left: 80rpx;
	}

	.order-submission .wrapper .item .list .payItem .name .iconfont {
		width: 44rpx;
		height: 44rpx;
		border-radius: 50%;
		text-align: center;
		line-height: 44rpx;
		background-color: #fe960f;
		color: #fff;
		font-size: 30rpx;
		margin-right: 15rpx;
	}

	.order-submission .wrapper .item .list .payItem .name .iconfont.icon-weixin2 {
		background-color: #41b035;
	}

	.order-submission .wrapper .item .list .payItem .name .iconfont.icon-zhifubao {
		background-color: #1677FF;
	}

	.order-submission .wrapper .item .list .payItem .tip {
		width: 49%;
		text-align: center;
		font-size: 26rpx;
		color: #aaa;
	}

	.order-submission .moneyList {
		margin-top: 12rpx;
		background-color: #fff;
		padding: 30rpx;
	}

	.order-submission .moneyList .item {
		font-size: 28rpx;
		color: #282828;
	}

	.order-submission .moneyList .item~.item {
		margin-top: 20rpx;
	}

	.order-submission .moneyList .item .money {
		color: #868686;
	}

	.order-submission .footer {
		width: 100%;
		height: 100rpx;
		background-color: #fff;
		padding: 0 30rpx;
		font-size: 28rpx;
		color: #333;
		box-sizing: border-box;
		position: fixed;
		bottom: 0;
		left: 0;
	}

	.order-submission .footer .settlement {
		font-size: 30rpx;
		color: #fff;
		width: 240rpx;
		height: 70rpx;
		background-color: #a7cf54;
		border-radius: 50rpx;
		text-align: center;
		line-height: 70rpx;
	}

	.footer .transparent {
		opacity: 0
	}
	.greeting_card {
		width: 100%;
		padding: 20rpx 30rpx;
		.greeting_hd {
			width: 100%;
			// margin-bottom: 20rpx;
		}
		textarea, input {
			width: 100%;
			background-color: #f8f8f8;
			margin-bottom: 10rpx;
			text-align: center;
			border-radius: 10rpx;
			box-sizing: border-box;
		}
		textarea {
			display: flex;
			align-items: center;
			height: 180rpx;
			padding: 0 20rpx 20rpx;
		}
		input {
			height: 90rpx;
			padding: 0 20rpx;
			margin-bottom: 0;
		}
	}
	
	.popup-content {
		padding: 0 40rpx 45rpx;
		.title {
			position: relative;
			width: 100%;
			height: 130rpx;
			line-height: 130rpx;
			text-align: center;
			font-size: 34rpx;
			border-bottom: 1px solid #eee;
		}
		
	}
	.payment .title .iconfont {
		position: absolute;
		right: 0rpx;
		top: 50%;
		transform: translateY(-50%);
		font-size: 38rpx;
		color: #8a8a8a;
		font-weight: normal;
	}
	.payment.on {
		transform: translate3d(0, 0, 0);
	}
	.payment .item {
		border-bottom: 1rpx solid #eee;
		height: 130rpx;
	}
	
	.payment .item .left {
		width: 610rpx;
	}
	
	.payment .item .left .text {
		width: 540rpx;
	}
	
	.payment .item .left .text .name {
		font-size: 32rpx;
		color: #282828;
	}
	.payment .item .left .text .recharge {
		display: inline-block;
		width: 130rpx;
		height: 40rpx;
		line-height: 40rpx;
		background-color: #EB3822;
		color: #fff;
		text-align: center;
		margin-left: 30rpx;
	}
	.payment .item .left .text .info {
		display: flex;
		align-items: flex-end;
		font-size: 24rpx;
		color: #999;
	}
	
	.payment .item .left .text .info .money {
		color: #ff9900;
	}
	
	.payment .item .left .iconfont {
		font-size: 45rpx;
		color: #09bb07;
	}
	
	.payment .item .left .iconfont.icon-zhifubao {
		color: #00aaea;
	}
	
	.payment .item .left .iconfont.icon-yuezhifu {
		color: #ff9900;
	}
	
	.payment .item .left .iconfont.icon-yuezhifu1 {
		color: #eb6623;
	}
	
	.payment .item .iconfont {
		font-size: 40rpx;
		color: #ccc;
	}
</style>
